<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>Title</title>
    <script src="UDB/darg.js"></script>
    <style>
        .demo{
            width: 80px;
            height: 80px;
            border-radius: 5px;
            background: burlywood;
            margin: 10px;
            display: inline-block;
            font-size: 13px;
            padding: 2px;
            top: 100px
        }
        #demo2{
            background: aquamarine;
            top: 200px;
        }
        #demo3{
            background: coral;
            top: 300px;
        }
    </style>
</head>
<body>
    <h3>可根据业务逻辑快速完成拖拽，拿来即用！！！</h3>
    <div id="demo1" class="demo">默认不允许超出视口</div>
    <div id="demo2" class="demo">总是允许拖拽</div>
    <div id="demo3" class="demo">总是不允许拖拽</div>
    <script>

        document.getElementById("demo1").darg();

        document.getElementById("demo2").darg(function () {
            return true;
        });

        document.getElementById("demo3").darg(function () {
            return false;
        });
    </script>
</body>
</html>